package leecode

import "fmt"

func getRow(rowIndex int) (result []int) {
	if rowIndex == 0 {
		return []int{1}
	}
	if rowIndex == 1 {
		return []int{1, 1}
	}
	dp := make([][]int, rowIndex+1)
	for i := 0; i <= rowIndex; i++ {
		dp[i] = make([]int, i+1)
	}
	fmt.Println(dp)
	//初始化dp
	for i := 0; i <= rowIndex; i++ {
		dp[i][0] = 1
		dp[i][len(dp[i])-1] = 1
	}
	target := 0
	for i := 2; i < len(dp); i++ {
		if i == rowIndex {
			target = 1
		}
		for j := 1; j < len(dp[i])-1; j++ {
			dp[i][j] = dp[i-1][j-1] + dp[i-1][j]
		}
		if target == 1 {
			result = append(result, dp[i]...)
			break
		}
	}
	return
}
